package com.xm.xmapp.dialog;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.xm.xmapp.AppFeedbackActivity;
import com.xm.xmapp.R;
import com.xm.xmapp.app.MyAppcation;
import com.xm.xmapp.tools.Tools;

public class AppCommentTipDialog extends Dialog implements
		View.OnClickListener {
	private Activity context;

	public AppCommentTipDialog(Activity context) {
		super(context, R.style.Dialog);
		// TODO Auto-generated constructor stub

		this.context = context;

	}

	@SuppressLint("InflateParams")
	public void init() {
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.dialog_app_comment_tip, null);
		TextView text1 = (TextView) view.findViewById(R.id.text1);
		TextView text2 = (TextView) view.findViewById(R.id.text2);
		TextView text3 = (TextView) view.findViewById(R.id.text3);

		text1.setOnClickListener(this);
		text2.setOnClickListener(this);
		text3.setOnClickListener(this);
		setContentView(view);

		// Window dialogWindow = getWindow();
		// WindowManager.LayoutParams lp = dialogWindow.getAttributes();
		// DisplayMetrics d = context.getResources().getDisplayMetrics(); //
		// 获取屏幕宽、高用
		// lp.width = (int) (d.widthPixels * 0.8); // 高度设置为屏幕的0.6
		// dialogWindow.setAttributes(lp);
	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		super.show();

		// setCancelable(false);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		init();

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.text1:

			dismiss();
			Tools.startPinjia();
			break;
		case R.id.text2:
			dismiss();
			Intent intent = new Intent(MyAppcation.getMyAppcation(),
					AppFeedbackActivity.class);
			context.startActivity(intent);
			break;
		case R.id.text3:
			dismiss();
			break;

		default:
			break;
		}
	}

}
